#!/bin/bash
set -e

while getopts  ":mp:" opts
do
        case  $opts  in
        m)
			markdup=true
			;;
		p)
			out_prefix=$OPTARG
			;;
		\?)
			echo `basename $0` '[-p out_prefix] <in.bam> <downsample_fraction>'
			exit 1
			;;
        esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then
        echo `basename $0` '[-p out_prefix] <in.bam> <downsample_fraction>'
        exit 1
fi

#-----------------------------------------------
. /mnt/ilustre/app/medical/tools/.var #---------
#-----------------------------------------------


echo;echo;echo picard DownsampleSam
java -jar ${tools_path}/picard-tools-1.119/DownsampleSam.jar \
I=$1 \
O=$out_prefix.downsample.bam \
RANDOM_SEED=null \
PROBABILITY=$2 \
CREATE_INDEX=true